package com.atguigu1.core.io

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

/**
 *
 * @description: 缓存案例
 * @time: 2021-03-12 11:45
 * @author: baojinlong
 **/
object Spark01IoSave {
  def main(args: Array[String]): Unit = {
    val conf: SparkConf = new SparkConf().setMaster("local[*]").setAppName("persistDemo")
    // 设置rdd分区数字
    val sparkContext = new SparkContext(conf)
    val rdd: RDD[(String, Int)] = sparkContext.makeRDD(Seq(
      ("nba", 1),
      ("cba", 2),
      ("wba", 3)
    ))
    rdd.saveAsTextFile("output1")
    rdd.saveAsObjectFile("output2")
    rdd.saveAsSequenceFile("output3")
    sparkContext.stop
  }

}